//
//  CallRecrodCell.m
//  NetPhone
//
//  Created by intel intel on 12-4-27.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "CallRecordListCell.h"

@implementation CallRecordListCell
@synthesize callRecord;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        UIImageView *tagView = [[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"icon_systemcall_normal"]]autorelease];
        tagView.contentMode = UIViewContentModeCenter;
        tagView.frame = CGRectMake(0, 0, 45, 45);
        [self.contentView addSubview:tagView];
        
        
        nameLabel = [[[UILabel alloc]initWithFrame:CGRectMake(45, 0, 150, 20)]autorelease];
        nameLabel.font = [UIFont systemFontOfSize:14];
        nameLabel.textColor = [UIColor blackColor];
        nameLabel.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:nameLabel];
        
        timeLabel = [[[UILabel alloc]initWithFrame:CGRectMake(45, 20, 150, 20)]autorelease];
        timeLabel.font = [UIFont systemFontOfSize:14];
        timeLabel.textColor = [UIColor grayColor];
        timeLabel.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:timeLabel];
        
        
        dateLabel = [[[UILabel alloc]initWithFrame:CGRectMake(200, 0, 80, 45)]autorelease];
        dateLabel.font = [UIFont systemFontOfSize:14];
        dateLabel.textColor = [UIColor grayColor];
        dateLabel.textAlignment = UITextAlignmentRight;
        dateLabel.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:dateLabel];
        
        
    }
    return self;
}

-(void)setCallRecord:(CallRecord *)_callRecord
{
    if (_callRecord != callRecord) {
        [callRecord release];
        callRecord = [_callRecord retain];
    }
    
    NSString *text = callRecord.phoneNum;
    nameLabel.text = text;
    
    timeLabel.text = callRecord.callTime;
    
    NSDateFormatter *datef=[[[NSDateFormatter alloc] init]autorelease];
    [datef setDateFormat:@"yyyy-MM-dd"];
    NSString *theDate = [datef stringFromDate:[NSDate date]];
    
    if ([theDate isEqualToString:callRecord.callDate]) {
        dateLabel.text = @"今天";
    }else{
        dateLabel.text = callRecord.callDate;
    }
    
    
}

-(void)dealloc
{
    [callRecord release];
    [super dealloc];
}


@end
